<?php
// SomeryC, a webcomic script by Zachary Weston Lewis
// Based on Somery by Robin de Graaf
// Copyright 2005-2006
// SomeryC is distributed under the Artistic License (see LICENSE.txt)
//
// ADMIN/LOGIN.PHP > 31-08-2007

session_start();
include("system/error.php"); 
extract($_POST);
extract($_GET);
if ($a == "logout") { 
   include("../config.php"); 
   include("system/functions.php"); 
  session_destroy();
   $login = TRUE; 
   include("./$skindir/header.php"); 
} 
if ($login) { 
   echo  " 
      <h1 id='login'>Login</h1>
      <table><tr><td colspan=2><form action='login.php' method='post'></td></tr> 
      <tr><td>username</td><td><input type='text' name='login_username' size=50></td></tr> 
      <tr><td>password</td><td><input type='password' name='login_password' size=50></td></tr> 
      <tr><td colspan='2'><input type='submit' value='Login' /></td></tr>
      "; 
} else { 
   include("../config.php"); 
   include("system/functions.php"); 
   if (!$login_username || !$login_password) { 
      include("./$skindir/header.php"); 
      echo $error[0]; 
   } else { 
      loaduser($login_username); 
      if ($login_username == $userdata['username']) { 
         $login_password = md5($login_password); 
         if ($login_password == $userdata['password']) { 
            $_SESSION['username'] = $login_username; 
            $_SESSION['password'] = $login_password; 
            include("./$skindir/header.php"); 
            echo "<meta http-equiv=Refresh content=0;URL='index.php'>"; 
         } else { 
            include("./$skindir/header.php"); 
            echo $error[1]; 
         } 
      } else { 
         include("./$skindir/header.php"); 
         echo $error[2]; 
      } 
   } 
} 
include("./$skindir/footer.php");
?>
